package com.cssw.fyzb.busi.api.acct;

import com.cssw.fyzb.busi.service.acct.RedPackService;
import com.cssw.fyzb.core.model.vo.acct.RedPackDetailsVo;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.Function;
import com.ydn.appserver.annotations.Parameter;
import com.ydn.appserver.annotations.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: zzf
 * @time: 2021/1/11 20:46
 */
@Function(description = "红包详情", parameters = {
        @Parameter(name = "redId", type = Type.String, description = "红包标识", required = true),
        @Parameter(name = "tradeType", type = Type.String, description = "交易类型", required = true)
})
@Component
public class RedPackDetails implements Action {
    private static final Logger logger = LoggerFactory.getLogger(RedPackDetails.class);

    @Autowired
    private RedPackService redPackService;

    @Override
    public Response execute(Request request) throws Exception {
        Long redId = request.getLong("redId");
        String tradeType = request.getString("tradeType");
        try {
            RedPackDetailsVo vo = redPackService.RedPackDetails(redId, tradeType);
            return Response.success().put("data", vo);
        } catch (Exception e) {
            logger.info("", e);
            return Response.fail("操作异常");
        }
    }
}
